<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/base_body_header.jsp" %>
<%@include file="../common/navbar.jsp" %>
<%@include file="../common/page_content_pre.jsp" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<link rel="stylesheet" href="${GLOBAL.staticJsPath}/assets/qiniu/fileupload.css"/>
<link rel="stylesheet" href="${GLOBAL.staticJsPath}/jquery-select2/3.4/select2.min.css"/>

<div class="page-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="widget-box">
                <div class="widget-header">
                    <h4>${not empty houseInfo.houseId?'修改':'添加'}二手豪宅</h4>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <form:form class="form-horizontal" modelAttribute="houseInfo"
                                   action="${GLOBAL.basePath}/houseInfo/save" method="post" id="houseInfoForm">
                            <form:hidden path="houseId"/>
                            <form:input path="houseType" value = "2" type = "hidden"></form:input>
                            <fieldset>
                                <div>
                                    <label class="col-sm-1"></label>
                                    <table>
                                        <tr>
                                            <td>小区：</td>
                                            <td class="col-sm-4">
                                                <form:select id="nbhId" path="nbhId"
                                                             class="js-example-basic-single" style="width:100%;"
                                                             onchange="selectNbh()">
                                                    <optgroup label="">
                                                        <option value="0" selected=selected>--请选择小区--</option>
                                                        <form:options items="${neighborhoodList}" itemLabel="nbhName"
                                                                      itemValue="nbhId" htmlEscape="false"/>
                                                    </optgroup>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="right">楼栋号：</td>
                                            <td>
                                                <form:select path="cellId" id="cellInfoId" onchange="selectCell()" style="width: 110px">
                                                    <option value="0">--楼栋号--</option>
                                                </form:select>&nbsp;
                                            </td>
                                            <td style="width: 60px;" align="right">单元号：</td>
                                            <td>
                                                <form:select path="unitNo" id="unitNoId" onchange="selectUnit()" style="width: 80px">
                                                    <option value="0">--单元号--</option>
                                                </form:select>&nbsp;
                                            </td>
                                            <td style="width: 60px;" align="right">门牌号：</td>
                                            <td>
                                                <form:select path="roomNo" id="roomNoId" style="width: 80px">
                                                    <option value="0">--门牌号--</option>
                                                </form:select>&nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <br>

                                <div class="form-group">
                                    <label class="col-sm-1"></label>
                                    <table>
                                        <tr>
                                            <td>
                                                <h4>房源基本信息</h4>
                                            </td>
                                            <td style="width: 60px; color: #0b6cbc" align="right">
                                                编号:
                                            </td>

                                            <td style="color: #0b6cbc" align="vertical-align:up;">
                                                    ${houseInfo.houseNo}
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <hr/>

                                <div>
                                    <label class="col-sm-1 control-label"></label>
                                    <table>
                                        <tr>
                                            <td>标题：</td>
                                            <td width="500px">
                                                <form:input path="title" htmlEscape="false" maxlength="50"
                                                            class="col-sm-10 required" placeholder="请输入标题"/>
                                                <span class="help-inline"><font color="red">*</font> </span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td>总价：</td>
                                            <td>
                                                <form:input path="totalPrice" htmlEscape="false" type="number"
                                                            class="required"/>
                                                <span class="help-inline"><font color="red">万*</font> </span>
                                                &nbsp;
                                                <span class="help-inline" id = "tpid" style="color: red"></span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                    </table>

                                    <label class="col-sm-1 control-label"></label>
                                    <table>
                                        <tr>
                                            <td>面积</td>
                                            <td>
                                                <form:input path="factArea" required="required" type="number"
                                                            value="${houseInfo.factArea}" style="width: 80px"/>m²
                                            </td>
                                            <td style="width: 60px;" align="right">楼层</td>
                                            <td>
                                                <form:input path="floors" required="required" type="number" style="width: 60px"/>
                                            </td>
                                            <td style="width: 60px;" align="right">总层数</td>
                                            <td>
                                                <form:input path="totalFloor" required="required" type="number" style="width: 60px"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td>装修：</td>
                                            <td>
                                                <form:select path="decoration">
                                                    <c:forEach items="${fns:getDictList('decorate')}" var="item">
                                                        <option value="${item.name}"
                                                                <c:if test="${item.name == houseInfo.decoration}">selected</c:if>>${item.value}</option>
                                                    </c:forEach>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="right">朝向：</td>
                                            <td>
                                                <form:select path="orientation">
                                                    <c:forEach items="${fns:getDictList('direction')}" var="item">
                                                        <option value="${item.name}"
                                                                <c:if test="${item.name == houseInfo.orientation}">selected</c:if>>${item.value}</option>
                                                    </c:forEach>
                                                </form:select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td>户型：</td>
                                            <td>
                                                <form:select path="bedroomNum" style="width: 50px">
                                                    <option value="0"
                                                            <c:if test="${houseInfo.bedroomNum == 0}">selected</c:if>>0
                                                    </option>
                                                    <option value="1"
                                                            <c:if test="${houseInfo.bedroomNum == 1}">selected</c:if>>1
                                                    </option>
                                                    <option value="2"
                                                            <c:if test="${houseInfo.bedroomNum == 2}">selected</c:if>>2
                                                    </option>
                                                    <option value="3"
                                                            <c:if test="${houseInfo.bedroomNum == 3}">selected</c:if>>3
                                                    </option>
                                                    <option value="4"
                                                            <c:if test="${houseInfo.bedroomNum == 4}">selected</c:if>>4
                                                    </option>
                                                    <option value="5"
                                                            <c:if test="${houseInfo.bedroomNum == 5}">selected</c:if>>5
                                                    </option>
                                                    <option value="6"
                                                            <c:if test="${houseInfo.bedroomNum == 6}">selected</c:if>>6
                                                    </option>
                                                    <option value="7"
                                                            <c:if test="${houseInfo.bedroomNum == 7}">selected</c:if>>7
                                                    </option>
                                                    <option value="8"
                                                            <c:if test="${houseInfo.bedroomNum == 8}">selected</c:if>>8
                                                    </option>
                                                    <option value="9"
                                                            <c:if test="${houseInfo.bedroomNum == 9}">selected</c:if>>9
                                                    </option>
                                                    <option value="10"
                                                            <c:if test="${houseInfo.bedroomNum == 10}">selected</c:if>>
                                                        10
                                                    </option>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="left">室</td>
                                            <td>
                                                <form:select path="parlorNum" style="width: 50px">
                                                    <option value="1"
                                                            <c:if test="${houseInfo.parlorNum == 1}">selected</c:if>>1
                                                    </option>
                                                    <option value="2"
                                                            <c:if test="${houseInfo.parlorNum == 2}">selected</c:if>>2
                                                    </option>
                                                    <option value="3"
                                                            <c:if test="${houseInfo.parlorNum == 3}">selected</c:if>>3
                                                    </option>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="left">厅</td>
                                            <td>
                                                <form:select path="kitchenNum" style="width: 50px">
                                                    <option value="1"
                                                            <c:if test="${houseInfo.kitchenNum == 1}">selected</c:if>>1
                                                    </option>
                                                    <option value="2"
                                                            <c:if test="${houseInfo.kitchenNum == 2}">selected</c:if>>2
                                                    </option>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="left">厨</td>
                                            <td>
                                                <form:select path="toiletNum" style="width: 50px">
                                                    <option value="0"
                                                            <c:if test="${houseInfo.toiletNum == 0}">selected</c:if>>0
                                                    </option>
                                                    <option value="1"
                                                            <c:if test="${houseInfo.toiletNum == 1}">selected</c:if>>1
                                                    </option>
                                                    <option value="2"
                                                            <c:if test="${houseInfo.toiletNum == 2}">selected</c:if>>2
                                                    </option>
                                                    <option value="3"
                                                            <c:if test="${houseInfo.toiletNum == 3}">selected</c:if>>3
                                                    </option>
                                                    <option value="4"
                                                            <c:if test="${houseInfo.toiletNum == 4}">selected</c:if>>4
                                                    </option>
                                                    <option value="5"
                                                            <c:if test="${houseInfo.toiletNum == 5}">selected</c:if>>5
                                                    </option>
                                                    <option value="6"
                                                            <c:if test="${houseInfo.toiletNum == 6}">selected</c:if>>6
                                                    </option>
                                                    <option value="7"
                                                            <c:if test="${houseInfo.toiletNum == 7}">selected</c:if>>7
                                                    </option>
                                                    <option value="8"
                                                            <c:if test="${houseInfo.toiletNum == 8}">selected</c:if>>8
                                                    </option>
                                                    <option value="9"
                                                            <c:if test="${houseInfo.toiletNum == 9}">selected</c:if>>9
                                                    </option>
                                                    <option value="10"
                                                            <c:if test="${houseInfo.toiletNum == 10}">selected</c:if>>10
                                                    </option>
                                                </form:select>
                                                卫
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td>车位：</td>
                                            <td>
                                                <form:input path="parkNum" id="parkNum" required="required"
                                                            value="${houseInfo.parkNum}" type="number"
                                                            style="width: 40px"/>个
                                            </td>
                                            <td style="width: 60px;" align="right">建筑年代:</td>
                                            <td>
                                                <input name="buildingYears" id = "buildingYears" readonly="true" style="width: 70px"
                                                       value=" <fmt:formatDate value='${houseInfo.buildingYears}' pattern='yyyy-MM'/>"
                                                       class=" required" onClick="WdatePicker({dateFmt:'yyyy-MM'})"/>
                                            </td>
                                        <tr/>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                    </table>
                                    <label class="col-sm-1 control-label"></label>
                                    <table>
                                        <tr>
                                            <td>业主姓名：</td>
                                            <td>
                                                <form:input path="ownerName" required="required" style="width: 100px"/>
                                            </td>
                                            <td style="width: 80px;" align="right">业主电话：</td>
                                            <td>
                                                <form:input path="ownerPhone" required="required" type="number"
                                                            style="width: 180px"/>
                                            </td>
                                            <td style="width: 60px;" align="right">钥匙:</td>
                                            <td>
                                                <form:select path="keyFlag">
                                                    <option value="1" <c:if test="${houseInfo.keyFlag == '1'}">selected</c:if>>有</option>
                                                    <option value="2" <c:if test="${houseInfo.keyFlag == '2'}">selected</c:if>>无</option>
                                                </form:select>
                                            </td>
                                            <td style="width: 60px;" align="right">现状:</td>
                                            <td>
                                                <form:select path="houseCurrent">
                                                    <c:forEach items="${fns:getDictList('house_current')}" var="item">
                                                        <option value="${item.name}"
                                                                <c:if test="${item.name == houseInfo.houseCurrent}">selected</c:if>>${item.value}</option>
                                                    </c:forEach>
                                                </form:select>
                                            </td>
                                        <tr/>
                                    </table>
                                    <label class="col-sm-1 control-label"></label>
                                    <table>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td>标签（最多三个）：</td>
                                            <td>
                                                <c:forEach items="${fns:getDictList('label')}" var="item">
                                                    <input id="${item.name}-LabeLId" name="label" type="checkbox"
                                                           onclick="checkInfo()"
                                                           value="${item.name}"/>${item.value}&nbsp;
                                                </c:forEach>
                                                <span id="labelSpanId" style="color: red"></span>
                                            </td>
                                        <tr/>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-1"></label>
                                    <table>
                                        <tr>
                                            <td>
                                                <h4>房源详细描述</h4>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <hr/>

                                <label class="col-sm-1 control-label"></label>

                                    <table>
                                        <tr>
                                            <td valign="top">
                                                【核心卖点】：
                                            </td>
                                            <td width="800px">
                                                <div class="col-sm-10">
                                                    <textarea name="categoryHX" class="col-sm-12" rows="8">${houseDesc0.text}</textarea>
                                                    <input type="hidden" name = "hxId" value="${houseDesc0.houseDescId}">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                【出售原因】：
                                            </td>
                                            <td width="800px">
                                                <div class="col-sm-10">
                                                    <textarea name="categoryYY" class="col-sm-12" rows="8">${houseDesc1.text}</textarea>
                                                    <input type="hidden" name = "yyId" value="${houseDesc1.houseDescId}">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                【景观特点】：
                                            </td>
                                            <td width="800px">
                                                <div class="col-sm-10">
                                                    <textarea name="categoryJG" class="col-sm-12" rows="8">${houseDesc2.text}</textarea>
                                                    <input type="hidden" name = "jgId" value="${houseDesc2.houseDescId}">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td valign="top">
                                                【坐落位置】：
                                            </td>
                                            <td width="800px">
                                                <div class="col-sm-10">
                                                    <textarea name="categoryWZ" class="col-sm-12" rows="8">${houseDesc3.text}</textarea>
                                                    <input type="hidden" name = "wzId" value="${houseDesc3.houseDescId}">
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                &nbsp;
                                <hr/>
                                <fieldset>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">房源图片（至少五张）</label>

                                        <div class="col-sm-6">
                                            <div id="photos" class="row" style="width:750px">
                                                <div id="container" class="col-xs-4">
                                                    <img src="${GLOBAL.staticImagePath}/add_bg.png">

                                                    <div class="add">
                                                        <img id="addfile" src="/images/add.png">
                                                    </div>
                                                </div>

                                                <c:if test="${photoList!= null || fn:length(photoList) == 0}">
                                                    <c:forEach items="${photoList}" var="item" varStatus="plist">
                                                        <div id="${item.photoSource}-id" class="col-xs-4"><img
                                                                id="${item.photoSource}"
                                                                src="${storeUrl}${item.photoSource}">

                                                            <div class="q-label"><input value="${item.photoDesc}"></div>
                                                            <div class="delete" onclick="deletePic($(this).parent())">
                                                                <img
                                                                        src="/images/delete.png"></div>
                                                        </div>
                                                    </c:forEach>
                                                </c:if>
                                            </div>
                                            <span id="uploadInfo" style="color: red"></span>
                                        </div>
                                    </div>
                                </fieldset>
                                <br>
                                <hr/>
                                <fieldset>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">户型图片（至少一张）</label>

                                        <div class="col-sm-6">
                                            <div id="photos-hx" class="row" style="width:750px">
                                                <div id="container" class="col-xs-4">
                                                    <img src="${GLOBAL.staticImagePath}/add_bg.png">

                                                    <div class="add">
                                                        <img id="addfile-hx" src="/images/add.png">
                                                    </div>
                                                </div>

                                                <c:if test="${photoList!= null || fn:length(photoList) == 0}">
                                                    <c:forEach items="${photoHXList}" var="item" varStatus="plist">
                                                        <div id="${item.photoSource}-id" class="col-xs-4"><img
                                                                id="${item.photoSource}"
                                                                src="${storeUrl}${item.photoSource}?imageView2/0/w/160/h/160">

                                                            <div class="q-label"><input value="${item.photoDesc}"></div>
                                                            <div class="delete" onclick="deletePicFX($(this).parent())">
                                                                <img
                                                                        src="/images/delete.png"></div>
                                                        </div>
                                                    </c:forEach>
                                                </c:if>
                                            </div>
                                            <span id="uploadInfoFX" style="color: red"></span>
                                        </div>
                                    </div>
                                    <input id="cellId" type="hidden" value="${houseInfo.cellId}">
                                    <input id="unitId" type="hidden" value="${houseInfo.unitNo}">
                                    <input id="roomId" type="hidden" value="${houseInfo.roomNo}">
                                </fieldset>
                            </fieldset>

                            <fieldset>
                                <div>
                                    <label class="col-sm-1">房源状态</label>
                                    <form:select path="houseStatus" class="col-sm-2">
                                        <c:forEach items="${fns:getDictList('house_status')}" var="item">
                                            <option value="${item.name}"
                                                    <c:if test="${item.name == houseInfo.houseStatus}">selected</c:if>>${item.value}</option>
                                        </c:forEach>
                                    </form:select>
                                </div>
                            </fieldset>

                            <div id="upload_file_container"></div>
                            <div id="upload_file_container_fy"></div>

                            <div class="form-actions center">
                                <button type="button" class="btn btn-sm btn-grey" id="go_back_btn">
                                    返回
                                    <i class="icon-reply icon-on-right bigger-110"></i>
                                </button>
                                <shiro:hasPermission name='houseInfo:edit'>
                                    <button type="button" class="btn btn-sm btn-success" id="save_btn">
                                        保存
                                        <i class="icon-save icon-on-right bigger-110"></i>
                                    </button>
                                </shiro:hasPermission>
                            </div>
                        </form:form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<%@include file="../common/page_content_suf.jsp" %>
<%@include file="../common/script.jsp" %>

<script type="text/javascript" src="${GLOBAL.staticJsPath}/assets/qiniu/plupload.full.min.js"></script>
<script type="text/javascript" src="${GLOBAL.staticJsPath}/assets/qiniu/moxie.min.js"></script>
<script type="text/javascript" src="${GLOBAL.staticJsPath}/assets/qiniu/qiniu.min.js"></script>
<script type="text/javascript" src="${GLOBAL.staticJsPath}/assets/my97/WdatePicker.js"></script>
<script type="text/javascript" src="${GLOBAL.staticJsPath}/uploadFile/houseInfo/fy-fileupload.js"></script>

<script type="text/javascript" src="${GLOBAL.staticJsPath}/uploadFile/houseInfo/hx-fileupload.js"></script>

<script src="${GLOBAL.staticJsPath}/jquery-select2/3.4/select2.min.js"></script>

<script type="text/javascript">
    var qiniuDomain = '${GLOBAL.basePath}';
    var qiniuPath = '${GLOBAL.qiniuPath}';

    $(document).ready(function () {
        $(".js-example-basic-single").select2(); //
        selectNbh();
        var labels = ${labelList};
        if (labels != null && labels != "" && labels != "no") {
            if (labels.length > 0) {
                for (var i = 0; i < labels.length; i++) {
                    $("#" + labels[i] + "-LabeLId").attr("checked", true);
                }
            }
        }

        $("#houseInfoForm").validate({
            ignore : ".noCheck",
            rules: {
                roomNo:{
                    remote:{
                        url: "${GLOBAL.basePath}/houseInfo/notExists",
                        type: "post",
                        dataType: "json",
                        data: {
                            houseId : function(){
                                return $("input[name='houseId']").val();
                            },
                            houseType : function(){
                                return $("input[name='houseType']").val();
                            },
                            nbhId : function(){
                                return $("#nbhId").val();
                            },
                            cellId : function(){
                                return $("#cellInfoId").val();
                            },
                            unitNo: function() {
                                return $("#unitNoId").val();
                            },
                            roomNo: function() {
                                return $("#roomNoId").val();
                            }
                        }
                    }
                }
            },
            messages: {
                mobile: {required: "用户登录名不能为空", remote: jQuery.format("用户登录名已存在")},
                confirmNewPassword: {equalTo: "输入与上面相同的密码"}
            },
            errorContainer: "#messageBox",
        });

        $("#save_btn").on("click", function () {
            saveBtn();
        });

        $("#go_back_btn").on("click", function () {
            goBack();
        });
    });

    function selectNbh() {
        var nbhId = $("#nbhId").val();
        $("#cellInfoId").empty();
        $.ajax({
            type: 'post',
            url: '${GLOBAL.basePath}/houseInfo/queryCellInfo',
            dataType: "json",
            data: {
                nbhId: nbhId
            },
            success: function (data) {
                if (data.data.length > 0) {
                    $("#cellInfoId").append("<option value='0'>--楼栋号--</option>");
                    data = data.data;
                    var opValue = "";
                    for (var i = 0; i < data.length; i++) {
                        var optionValue;
                        var cellIdVal = $("#cellId").val();

                        if(opValue == data[i].buildingNo){
                            continue;
                        }
                        opValue = data[i].buildingNo;

                        if (cellIdVal != "") {
                            if (data[i].cellId == cellIdVal) {
                                optionValue = "<option value='" + data[i].cellId + "'selected = 'selected'>" + data[i].buildingNo + "</option>";
                                $("#cellId").val("");
                            }
                        } else {
                            optionValue = "<option value='" + data[i].cellId + "'>" + data[i].buildingNo + "</option>";
                        }

                        $("#cellInfoId").append(optionValue);
                    }
                } else {
                    $("#cellInfoId").append("<option value='0'>--请选择楼号--</option>");
                }
            }
        });
        selectCell();
    };
    function selectCell(){
        var nbhId = $("#nbhId").val();
        var cellInfoId = $("#cellInfoId").find("option:selected").text();
        $("#unitNoId").empty();
        $.ajax({
            type: 'post',
            url: '${GLOBAL.basePath}/houseInfo/queryCellInfo',
            dataType: "json",
            data: {
                nbhId: nbhId,
                cellInfoId: cellInfoId
            },
            success: function (data) {
                if (data.data.length > 0) {
                    $("#unitNoId").append("<option value='0'>--单元号--</option>");
                    data = data.data;
                    var opValue = "";
                    for (var i = 0; i < data.length; i++) {
                        var optionValue;
                        var cellIdValUnit = $("#unitId").val();

                        if(opValue == data[i].unitNum){
                            continue;
                        }
                        opValue = data[i].unitNum;

                        if (cellIdValUnit != "") {
                            if (data[i].unitNum == cellIdValUnit) {
                                optionValue = "<option value='" + data[i].unitNum + "'selected = 'selected'>" + data[i].unitNum + "</option>";
                                $("#unitId").val("");
                            }
                        } else {
                            optionValue = "<option value='" + data[i].unitNum + "'>" + data[i].unitNum + "</option>";
                        }
                        $("#unitNoId").append(optionValue);
                    }
                } else {
                    $("#unitNoId").append("<option value='0'>--单元号--</option>");
                }
            }
        })
        selectUnit();
    };

    function selectUnit(){
        var nbhId = $("#nbhId").val();
        var cellInfoId = $("#cellInfoId").find("option:selected").text();
        var unitNoId = $("#unitNoId").val();
        $("#roomNoId").empty();
        $.ajax({
            type: 'post',
            url: '${GLOBAL.basePath}/houseInfo/queryCellInfo',
            dataType: "json",
            data: {
                nbhId: nbhId,
                cellInfoId: cellInfoId,
                unitNoId : unitNoId
            },
            success: function (data) {
                if (data.data.length > 0) {
                    $("#roomNoId").append("<option value='0'>--门牌号--</option>");
                    data = data.data;
                    for (var i = 0; i < data.length; i++) {
                        var optionValue;
                        var cellIdValRoom = $("#roomId").val();

                        if (cellIdValRoom != "") {
                            if (data[i].residenters == cellIdValRoom) {
                                optionValue = "<option value='" + data[i].residenters + "'selected = 'selected'>" + data[i].residenters + "</option>";
                                $("#roomId").val("");
                            }
                        } else {
                            optionValue = "<option value='" + data[i].residenters + "'>" + data[i].residenters + "</option>";
                        }
                        $("#roomNoId").append(optionValue);
                    }
                } else {
                    $("#roomNoId").append("<option value='0'>--门牌号--</option>");
                }
            }
        })
    };

    function goBack() {
        document.location.href = "${GLOBAL.basePath}/houseInfo/list";
    }

    function saveBtn() {
        var houseStatus = $("#houseStatus").val();
        if(houseStatus == 1){
            $("#totalPrice").addClass("noCheck");
            $("#factArea").addClass("noCheck");
            $("#parkNum").addClass("noCheck");
            $("#buildingYears").addClass("noCheck");
            $("#ownerName").addClass("noCheck");
            $("#ownerPhone").addClass("noCheck");

            getAllImageInfoFX();
            getAllImageInfo();

            $("#houseInfoForm").submit();
        }else {
            $("#totalPrice").removeClass("noCheck");
            $("#factArea").removeClass("noCheck");
            $("#parkNum").removeClass("noCheck");
            $("#buildingYears").removeClass("noCheck");
            $("#ownerName").removeClass("noCheck");
            $("#ownerPhone").removeClass("noCheck");

            if($("#totalPrice").val() >= 800){
                var chk_value = [];
                $('input[name="label"]:checked').each(function () {
                    chk_value.push($(this).val());
                });
                if (chk_value.length > 3) {
                    $("#labelSpanId").html("不能超过三个标签");
                    $("#1-LabeLId").focus();
                } else {
                    getImageKeys();
                };
            }else{
                $("#totalPrice").focus();
                $("#tpid").html("豪宅价格不能低于800万");
            }
        }
    };
    function checkInfo() {
        $("#labelSpanId").html("");
    }

    function getImageKeys() {
        var dataFX = getAllImageInfoFX();
        var data = getAllImageInfo();
        if (data.success) {
            if (data.size > 4) {
                if (dataFX.size > 0) {
                    $("#houseInfoForm").submit();
                } else {
                    $("#uploadInfoFX").html("户型图片不能少于1张");
                    return;
                }
            } else {
                $("#uploadInfo").html("房源图片不能少于5张");
                return;
            }
        } else {
            alert(data.msg);
        }
    }
</script>
